<template>
	<view class="wrap">
		<u-row gutter="16"  class="header">
			<u-col span="3">
				<view >
				
					编制：{{itemInfo.nickname}}{{itemInfo.publishtime}}
				</view>
			</u-col>
			<u-col span="3">
				<view class="demo-layout bg-purple">
					校对：{{itemInfo.jdname}}{{itemInfo.jddate}}
				</view>
			</u-col>
			<u-col span="3">
				<view class="demo-layout bg-purple">
					审核：{{itemInfo.shname}}{{itemInfo.shdate}}
				</view>
			</u-col>
			<u-col span="3">
				<view class="demo-layout bg-purple">
					批准：{{itemInfo.pzname}} {{itemInfo.pzdate}}
				</view>
			</u-col>
		
		</u-row>
		<u-row gutter="16" class="fwjlContntDiv">
			<u-col span="12">
				<view class="demo-layout bg-purple">
					现需对：
				
					{{itemInfo.header}}做如下更改:
				</view>
			</u-col>
			<u-col span="12">
				<view class="demo-layout bg-purple">
					<uni-text>说明：</uni-text>
					<!-- {{reason(itemInfo.reason)}} -->
					{{itemInfo.sm}}
				</view>
			</u-col>
			
		
			
			<u-col span="12">
				<view class="demo-layout bg-purple" v-if="addNum>0">
					
					<uni-text>增加零件如下：</uni-text>
					<u-table >				
							<u-tr>
								<u-th>工位</u-th>
								<u-th>图号</u-th>
								<u-th>名称</u-th>
								<u-th>数量</u-th>
								<u-th>库存处理意见</u-th>
								<u-th>备注</u-th>
							</u-tr>
							<u-tr v-for="(data,i) in itemInfo.datas"  v-if="data.state=='增加'">
								
								<u-td>{{data.gw}}</u-td>
								<u-td>{{data.ljh}}</u-td>
								<u-td>{{data.mc}}</u-td>
								<u-td>{{data.sl}}</u-td>
								<u-td>{{data.kc}}</u-td>
								<u-td>{{data.bz}}</u-td>
							</u-tr>
						</u-table>
				</view>
				<view class="demo-layout bg-purple" v-else>
					<uni-text>没有增加件！</uni-text>
				</view>
			</u-col>
			<u-col span="12">
				<view class="demo-layout bg-purple"  v-if="reduceNum>0">
					<uni-text>减少零件如下：</uni-text>
					<u-table >				
							<u-tr>
								<u-th>工位</u-th>
								<u-th>图号</u-th>
								<u-th>名称</u-th>
								<u-th>数量</u-th>
								<u-th>库存处理意见</u-th>
								<u-th>备注</u-th>
							</u-tr>
							<u-tr v-for="(data,i) in itemInfo.datas"  v-if="data.state=='减少'">
								<u-td>{{data.gw}}</u-td>
								<u-td>{{data.ljh}}</u-td>
								<u-td>{{data.mc}}</u-td>
								<u-td>{{data.sl}}</u-td>
								<u-td>{{data.kc}}</u-td>
								<u-td>{{data.bz}}</u-td>
							</u-tr>
						</u-table>
				</view>
				<view class="demo-layout bg-purple" v-else>
					<uni-text>没有减少件！</uni-text>
				</view>
			</u-col>
			
			<u-col span="12">
				<view class="demo-layout bg-purple">
					<uni-text>签收：</uni-text>
					<u-table >
							<u-tr>
								<u-th>发往单位</u-th>
								<u-th>签名/日期</u-th>
							
							</u-tr>
							<u-tr v-for="(qsi,i) in itemInfo.qs">
								<u-td>{{qsi.bmname}}</u-td>
								<u-td>{{qsi.qsname}}{{qsi.qstime}}</u-td>
						
							</u-tr>
						</u-table>
				</view>
			</u-col>
			
			
		</u-row>	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				itemInfo:[],
				picArr:[],
				addNum:0,
				reduceNum:0
			}
		},
		methods: {
			getLsggdInfo(id) {
				var phoArr = new Array();
				this.$u.api.lsggd.getInfo({
						id: id
					})
					.then(res => {
						console.log(res)
						
						// var photoArr = new Array();
						
						this.itemInfo = res.data
						// this.picArr= this.picIni(this.itemInfo.pics)
				
				var datas=res.data.datas
				for (var i = 0; i < datas.length; i++) {
					if(datas[i].state=="增加")
					{
						this.addNum=this.addNum+1
					}
					if(datas[i].state=="减少")
					{
						this.reduceNum=this.reduceNum+1
					}
				}
					
					});
			
			},
			reason(str){
				let codeArr=['SJ','GY','SJXC'];
				let strArr=['设计','工艺','设计现场更改'];
				var n=codeArr.indexOf(str)
				if(n!=-1){
					return strArr[n]
				}else{
					return '其他'
				}
			},
			day(str){
				let codeArr=['day','night'];
				let strArr=['白班','夜班'];
				var n=codeArr.indexOf(str)
				if(n!=-1){
					return strArr[n]
				}else{
					return '其他'
				}
			},		  
			leibie(str){
				let codeArr=['lbj','sj','gy','zp','bzj'];
				let strArr=['零部件','设计','工艺','装配','标准件'];
				var n=codeArr.indexOf(str)
				if(n!=-1){
					return strArr[n]
				}else{
					return '其他'
				}
			},
			picIni(strs){ 
			
				
				strs=strs.replaceAll("&quot;","\"");
				
	
				
				
			return JSON.parse(strs)
			},
			getImage(url){
				return "http://172.16.56.250/solve/Public/"+url
			},
			imgPreview(n) {
			var photos=this.picArr
				var urls=new Array();
				for (var i = 0; i < photos.length; i++) {
					urls.push(this.getImage(photos[i].savename))
				}
				uni.previewImage({
					current:n,//为当前显示图片的链接/索引值，不填或填写的值无效则为 urls 的第一张
					indicator: "default",//图片指示器样式，可取值："default" - 底部圆点指示器； "number" - 顶部数字指示器； "none" - 不显示指示器。
					loop: true,
					urls: urls,
			
				})
			},
		},
		onLoad: function(option) { //option为object类型，会序列化上个页面传递的参数
			
			this.getLsggdInfo(option.id)
			
			
		}
	}
</script>

<style lang="scss" scoped>
	.header{
		background-color: #789fe1;
		padding: 10rpx;
		color:#F7F7F7;
		font-weight: bold;
	}
	.u-icon{
		margin-right: 6rpx;
	}
	.fwjlContntDiv{
		padding: 10rpx 15rpx;
		uni-text{
			font-weight: bold;
		}
	
		
	}
</style>
